package com.huluobo.a2109mvpimdemo.splash;

import android.content.Intent;

import com.huluobo.a2109mvpimdemo.MainActivity;
import com.huluobo.a2109mvpimdemo.R;
import com.huluobo.a2109mvpimdemo.base.BaseActivity;
import com.huluobo.a2109mvpimdemo.view.MyView;
import com.huluobo.a2109mvpimdemo.login.LoginActivity;

public class SplashActivity extends BaseActivity<SplashContract.View, SplashPresenter> implements SplashContract.View {

    private MyView splash_my_view;

    @Override
    protected void initData() {
        presenter = new SplashPresenter();
    }

    @Override
    protected void initView() {
        splash_my_view = findViewById(R.id.splash_my_view);
        splash_my_view.start(1);
        splash_my_view.setOnAnimEndListener(() -> presenter.checkIsLoggedInBefore());
    }

    @Override
    protected int bindingLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    public void isLoggedIn() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }

    @Override
    public void isNotLoggedIn() {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
    }
}